home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gekkan Dennou Club 147
/
Gekkan Dennou Club - 2000.8 Vol. 147 (Japan).7z
/
Gekkan Dennou Club - 2000.8 Vol. 147 (Japan) (Track 1).bin
/
docs
/
complex
/
palettbl.c
< prev
next >
Wrap
C/C++ Source or Header
|
2000-05-22
|
823b
|
35 lines
#include <stdio.h>
#include <stdlib.h>
#include <iocslib.h>
#include <math.h>
#define C_PI (3.14159265358979323846264338328) /* pi */
extern unsigned short *paTable; /* パレットテーブル */
extern int mxCnt; /* 回数制限(1~65535) */
/* パレットテーブルを作る */
void make_palet_table()
{
unsigned short *p;
int n;
paTable = malloc((mxCnt + 1) * sizeof(unsigned short));
if (paTable == NULL) {
printf("Can't allocate memory\n");
exit(1);
}
p = paTable;
for (n = 0; n < mxCnt; n++) {
double t = n / (mxCnt / 15.0);
int u, v;
u = (int)(cos((t) * C_PI) * 14.0 + 26.5);
u = (u < 32) ? u : 31;
v = (int)(cos((t + 1.0) * C_PI) * 9.0 + 23.5);
v = (v < 32) ? v : 31;
*p++ = (unsigned short)HSVTORGB((192 * n) / mxCnt, u, v);
}
*p = 0;
}